import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import RotationRuler from './components/RotationRuler';

const TestRotationRuler = () => {
  const [rotationValue, setRotationValue] = useState(0);

  return (
    <View style={styles.container}>
      <Text style={styles.title}>旋转刻度尺测试</Text>
      <Text style={styles.valueText}>当前值: {rotationValue.toFixed(1)}°</Text>
      
      <RotationRuler
        value={rotationValue}
        minValue={-45}
        maxValue={45}
        step={1}
        onValueChange={(value) => {
          console.log('值变化:', value);
          setRotationValue(value);
        }}
        style={styles.ruler}
      />
      
      <Text style={styles.instructions}>
        测试说明：{'\n'}
        1. 滑动刻度尺应该有吸附效果{'\n'}
        2. 松手时应该自动吸附到最近的整数刻度{'\n'}
        3. 移动端应该有震动反馈{'\n'}
        4. 不应该在松手时重置到0.0
      </Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
    justifyContent: 'center',
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    textAlign: 'center',
    marginBottom: 20,
  },
  valueText: {
    fontSize: 18,
    textAlign: 'center',
    marginBottom: 30,
    color: '#333',
  },
  ruler: {
    marginVertical: 40,
  },
  instructions: {
    fontSize: 14,
    color: '#666',
    textAlign: 'center',
    marginTop: 40,
    lineHeight: 20,
  },
});

export default TestRotationRuler;
